
//JavaScript代码区域
layui.use(['element','jquery','layer'], function () {
    var element = layui.element;
    var $ =  layui.$;
    var layer = layui.layer;
    var id = $("input[type = 'hidden']").val();
    var signInTimes = $("#signInTimes").val();
    var signOutTimes =$("#signOutTimes").val();
    var lateTimes = $("#lateTimes").val();
    var leaveEarlyTime =$("#leaveEarlyTime").val();
    console.log(signInTimes);

    $("#signIn").on("click",function () {
        $.ajax({
            url: '/sign/signIn?id='+id,
            success: function (data) {
                layer.confirm(data.msg, function () {
                    document.location.reload();
                })
            },
            error: function () {
                layer.alert("签到失败")
            }
        });
    });
    $("#signOut").on("click",function () {
        $.ajax({
            url: '/sign/signOut?id='+id,
            async: false,
            success: function (data) {
                layer
                layer.confirm(data.msg, function () {
                    document.location.reload();
                })
            },
            error: function () {
                layer.alert("签退失败")
            }
        });
    });



    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));

    // 指定图表的配置项和数据
    var option = {
        title: {
            text: '本月考勤信息'
        },
        tooltip: {},
        legend: {
            data:['类别']
        },
        xAxis: {
            data: ["签到次数","签退次数","迟到次数","早退次数"]
        },
        yAxis: {},
        series: [{
            name: '次数',
            type: 'bar',
            data: [signInTimes, signOutTimes, lateTimes,leaveEarlyTime]
        }]
    };
    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
});
